package com.snbc.util;

import org.apache.hadoop.hbase.util.Bytes;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;

public class PropertiesUtil {
//	private static Logger logger = LogManager.getLogger(PropertiesUtil.class);
	private static Properties pro = new Properties();
	public static Properties getPro() {
		return pro;
	}

	static {
		load();
	}

	public static byte[] statisticFamily(){
		String tb_fa=pro.getProperty("statistic.table","banknote:info");
		return Bytes.toBytes(tb_fa.split(":")[1]);
	}
	public static String statisticTable(){
		String tb_fa=pro.getProperty("statistic.table","banknote:info");
		return tb_fa.split(":")[0];
	}
	
	public static int getCacheSize(){
		String cache=pro.getProperty("hbase.scan.cache","500");
		return Integer.parseInt(cache);
	}
	public static String getStaticsMode(){
		return pro.getProperty("statistic.mode","all");
	}
	public static double getCompressRate(){
		String rate=pro.getProperty("compress.rate","0.16");
		return Double.parseDouble(rate);
	}
	public static void load() {
		try {
//			System.out.println(PropertiesUtil.class.getResource("/"));
			pro.load(new InputStreamReader(PropertiesUtil.class.getClassLoader().getResourceAsStream("conf.properties"), "UTF-8"));
		} catch (IOException e) {
			e.printStackTrace();
		}


	}

}
